package com.ideal.manage.esms.controller.diagnostic;

import com.ideal.manage.esms.bean.DTO.PageDto;
import com.ideal.manage.esms.bean.diagnostic.Algorithm;
import com.ideal.manage.esms.bean.diagnostic.Diagnostic;
import com.ideal.manage.esms.bean.project.ArithmeticManage;
import com.ideal.manage.esms.service.project.ArithmeticManageService;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("diagnostic")
public class AlgorithmController {
    @Resource
    private ArithmeticManageService arithmeticManageService;

    /**
     * 算法列表请求
     *
     * @param model
     */
    @RequestMapping("diagnostic_algorithm_manager")
    public void diagnosticAlgorithmManager(Model model) {

    }

    /**
     * 设备算法数据请求
     * @param pageNum
     * @param request
     * @return
     */
    @RequestMapping("algorithm_data")
    @ResponseBody
    public PageDto algorithmData(int pageNum, HttpServletRequest request) {
        Page<ArithmeticManage> page = arithmeticManageService.findAllManages(pageNum, request);
        List<ArithmeticManage> arithmeticManages = page.getContent();
        long total = page.getTotalElements();
        PageDto pageDto = new PageDto();
        pageDto.setRows(arithmeticManages);
        pageDto.setTotal(total);
        return pageDto;
    }

    @RequestMapping("algorithm_add")
    public void algorithmAdd(Model model){
        System.out.println("algorithm........");
    }
}
